import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;


public class AncaPerl {
	
	
	
/**
 * @param args
 * @throws IOException 
 */
public static void main(String[] args) throws IOException {

	//running perl command
	String command = "c:\\Anca\\ant\\bin\\ant.bat -buildfile activate.xml";
	
	Process process = Runtime.getRuntime().exec(command);
	BufferedReader reader1 = new BufferedReader(new InputStreamReader(process.getInputStream()));
	BufferedReader reader2 = new BufferedReader(new InputStreamReader(process.getErrorStream()));
	
	String input = null;
	PrintWriter writer = new PrintWriter(new OutputStreamWriter(new BufferedOutputStream(process.getOutputStream())), true);
    writer.println(input);
    writer.flush();
    writer.close();
	int exitVal = 0;
		try {
			exitVal = process.waitFor();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        System.out.println("\n****************************");
        System.out.println("Command: " +command);
        System.out.println("Exit Value = " + exitVal);
        
     System.out.println("Outpustream is:" + input);
     String line;
     boolean finished = true;
     while((line = reader1.readLine()) != null) {
        finished = false; 
		System.out.println(line);
     }
}

}

